
package Scene;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;


/**
 *
 * @author henriquediomede
 */
public class InputControl implements KeyListener, MouseMotionListener
{
    
    public InputControl()
    {
        keyboard = new int[4];
        for(int i = 0; i < keyboard.length; i++)
            keyboard[i] = 0;
    }
    
  
    public static int[] getInput()
    {
        return keyboard;
    }
    
    public static int mouseHorizontalPosition()
    {
        return horizontalPosition;
    }
     
     
    public static int mouseVerticalPosition()
    {
        return verticalPosition;
    }
    
    
    

    public void keyTyped(KeyEvent ke) 
    {
        
    }

    public void keyPressed(KeyEvent ke) 
    {
        switch(ke.getKeyCode())
        {
            case KeyEvent.VK_D:
               keyboard[0] = 1;
                break;
                
            case KeyEvent.VK_A:
                keyboard[1] = 1;
                break;
                
            case KeyEvent.VK_W:
                keyboard[2] = 1;
                break;
                
            case KeyEvent.VK_S:
                keyboard[3] = 1;
                break;
        }
    }

    public void keyReleased(KeyEvent ke) 
    {
         switch(ke.getKeyCode())
        {
            case KeyEvent.VK_D:
               keyboard[0] = 0;
                break;
                
            case KeyEvent.VK_A:
                keyboard[1] = 0;
                break;
                
            case KeyEvent.VK_W:
                keyboard[2] = 0;
                break;
                
            case KeyEvent.VK_S:
                keyboard[3] = 0;
                break;
        }
    }
    
   
    public void mouseDragged(MouseEvent me) 
    {
        
    }

    public void mouseMoved(MouseEvent me) 
    {
       horizontalPosition = me.getX();
       verticalPosition = me.getY();
    }
    
   
    private static int keyboard[];
    private static int horizontalPosition = 0;
    private static int verticalPosition = 0;

}
